package com.roc.dao.impl;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.roc.dao.DaoException;
import com.roc.dao.IBankCardFourKeyDao;
import com.roc.pojo.Operators;

@Repository
public class BankCardFourKeyDaoImpl extends BaseDaoImpl implements IBankCardFourKeyDao {
    
	/**
	 * 删除t_wechat_validate
	 */
	@Override
	public int delWechatValidateInfo(String accountNo, Operators op) throws DaoException {
		int i = 0;
		try {
			Session session = sessionFactory.getCurrentSession();
			StringBuffer sb = new StringBuffer();
			sb.append( "DELETE FROM t_wechat_validate t \n" );
			sb.append( " WHERE t.account_no=").append(accountNo).append("\n");
			Query query = session.createSQLQuery(sb.toString());
			i = query.executeUpdate();	
		}catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new DaoException("删除银行卡四要素信息出错");
		}
		return i;
		
	}

	/**
	 * 删除apstfr.TBL_MGM_RISK_LEVEL
	 */
	@Override
	public int delMgmRiskLexelInfo(String accountNo, Operators op) throws DaoException {
		int i = 0;
		try {
			Session session = sessionFactory.getCurrentSession();
			String sql = "delete from apstfr.TBL_MGM_RISK_LEVEL l where l.risk_num_type = 'card' and l.risk_num= '" + accountNo + "'";
			Query query = session.createSQLQuery(sql);
			i = query.executeUpdate();	
		}catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new DaoException("删除核心系统四要素关联信息出错");
		}
		return i;
	}

}
